<template>
  <transition name="slide">
    <div class="modal" v-show="showModal">
      <div class="mask"></div>
      <div class="modal-dialog">
        <div class="modal-header">
          <span>{{title}}</span>
          <a href="javascript:;" @click="$emit('cancel')" class="icon-close"></a>
        </div>
        <div class="modal-body">
          <slot name="body"> </slot>
        </div>
        <div class="modal-footer">
            <a href="javascript:;" v-if="btnType==1" @click="$emit('submit')" class="btn">{{sureText}}</a>
            <a href="javascript:;" v-if="btnType==2" @click="$emit('cancel')" class="btn">{{cancelText}}</a>
          <div class="btn-group" v-if="btnType==3">
            <a href="javascript:;" @click="$emit('submit')" class="btn">{{sureText}}</a>
            <a href="javascript:;" @click="$emit('cancel')" class="btn btn-default">{{cancelText}}</a>
          </div>
        </div>
      </div>
    </div>
  </transition>
</template>

<script>
export default {
  name: "modal",
  props: {
    // 弹框类型 小中大 表单form
    modalType: {
      type: String,
      default: "from",
    },
    // 弹框标题
    title: String,
    // 按钮类型 1 确定 2取消 3确定取消
    btnType: String,
    // 按钮
    sureText: {
      type: String,
      default: "确定",
    },
    cancelText: {
      type: String,
      default: "取消",
    },
    // 是否显示弹框
    showModal: Boolean,
  },
};
</script>

<style lang="scss">
@import "../assets/scss/config.scss";
@import "../assets/scss/mixin.scss";
@import "../assets/scss/modal.scss";
</style>